package com.example.mychatroom.controller;

import com.example.mychatroom.model.Message;
import com.example.mychatroom.serviceApi.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


@RequestMapping("/message")
@RestController
public class MessageController {
    @Autowired
    private MessageService messageService;

    @RequestMapping("/getMessage")
    public Object getMessageBuSessionId(HttpServletRequest request, @RequestParam("sessionId")Integer sessionId) {
        List<Message> messages = messageService.getMessageBySessionId(sessionId);
        return messages;
    }

}
